// OgreDwarf.cpp : Defines the entry point for the DLL application.
//

#include "stdinc.h"
#include "Main/App.h"
#include "DwarfFort/Interface.h"
#include "rebase.h"
#include <stdio.h>


Main::App *theApp = NULL;


const DWORD WinMainLoc = 0x00518C70;
#pragma pack (push,1)
struct hook
{
	unsigned short call;
	DWORD address;
	unsigned char ret;
	hook(DWORD address)
	{
		call = 0x15FF;
		ret = 0xC3;
		this->address = address;
	}
};
#pragma pack (pop)

bool loaded = false;


HMODULE hDLL;

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	hDLL = hModule;
	switch (ul_reason_for_call) 
	{
		case DLL_PROCESS_ATTACH:
		  break;
		case DLL_PROCESS_DETACH:
		  break;
		case DLL_THREAD_ATTACH:
		  break;
		case DLL_THREAD_DETACH:
		  break;
	}
    return TRUE;
}

extern "C"
{
	__declspec(dllexport) void CustWinMain()//HINSTANCE app)
	{ 

		//_asm int 3;
		//MessageBox(NULL,"Injected, now attach","blearg",MB_OK);
		Sleep(30);
		theApp = new Main::App();
		if(theApp->Setup())
			theApp->MainLoop();
		delete theApp;
			
	}
}

